package work.lrl.counter_mapping;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import core.util.TransformCsvData;

import java.nio.charset.Charset;
import java.util.List;

public class Demo {
    static private final String dir = "2023-11-09\\";

    public static void main(String[] args) {
        JSONArray array = new JSONArray();
        TransformCsvData.peekCsv(file, 0, s -> {
            if (StrUtil.isNotBlank(s[0])) {
                array.add(s[0]);
            }
        });
        String format = String.format(mongoQuery, array.toString());
        FileUtil.writeString(format,queryFile, Charset.defaultCharset());
    }

    static private final String basePath = "C:\\work-records\\l陆叶\\l-lrl门店匹配\\" + dir;
    static private final String file = basePath + "code.csv";
    static private final String queryFile = basePath + "query.js";

    static private final String mongoQuery = "db.lrl_counter.find({code:{$in:%s}})";
}
